package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-06 15:50
 */
public class Solution_0191 {
    /**
     * 统计输入数字串1的个数
     *
     * @param n
     * @return
     */
    public int hammingWeight(int n) {
        int count = 0;
        while (n / 2 > 0 || n % 2 > 0) {
            if (n % 2 == 1) {
                count++;
            }
            n /= 2;

        }
        return count;
    }
}
